//
//  QRViewController.m
//  体育商城
//
//  Created by  on 2022/9/24.
//

#import "QRViewController.h"

@interface QRViewController ()<CameraViewDelegate>
@property (strong, nonatomic) IBOutlet CameraView *cameview;

@end

@implementation QRViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    [self initUI];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    dispatch_async(dispatch_get_main_queue(), ^{
        self.cameview.type = CameraViewTypeQr;
    });
    [self.navigationController setNavigationBarHidden:YES animated:NO];
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:NO];
    [self.cameview.session stopRunning];
}
- (void)initUI{
    self.cameview.delegate = self;
}

- (IBAction)actionForBtn:(UIButton *)sender {
    [self backBtnAction];
}
#pragma mark - EPCameraViewDelegate
- (void)finished:(NSData *)imgData :(NSString *)resultString{
    [self.cameview.session stopRunning];
    [self alert:LS(@"结果") msg:[NSString stringWithFormat:@"%@%@",LS(@"订单号: "),resultString] left:^{
        [self.cameview.session startRunning];
    } right:^{
        [self backBtnAction];
        if (self.block) {
            self.block(resultString);
        }
    }];
}
- (void)maskLayer:(cameraMaskLayer *)maskLayer :(UIView *)scanView{
    maskLayer.maskColor = [UIColor colorHex:@"#FFFFFF"];
    scanView.frame = CGRectMake(50, SCREEN_HEIGHT - SCREEN_WIDTH + 100, SCREEN_WIDTH - 100, SCREEN_WIDTH - 100);
}
- (BOOL)scanLine:(UIView *)scanLine :(CABasicAnimation *)animation{
    return YES;
}
@end
